<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	xmlns:ui="http://java.sun.com/jsf/facelets">

<body>
	<ui:composition template="/template/template.xhtml">
		<ui:define name="title">Privileges Information</ui:define>
		<ui:define name="manuBar">
			<h:form>
				<p:menubar autoSubmenuDisplay="true" id="menu"
					style="font-size:small">
					<p:menuitem value="Home" url="/controlling/index.xhtml"
						icon="ui-icon-document" immediate="true"
						onstart="waiteDialog.show();" />
					<p:menuitem value="Administration Index"
						url="/controlling/administration/administrationIndex.xhtml"
						icon="ui-icon-gear" immediate="true" onstart="waiteDialog.show();" />
					<p:menuitem value="Add privilege" icon="ui-icon-document"
						update=":frm_privilege" immediate="true"
						actionListener="#{privilegeBean.toAddPrivilege}"
						oncomplete="privilegeDlg.show()" />
				</p:menubar>
			</h:form>
		</ui:define>
		<ui:define name="content">
			<p:panel header="privileges Information">
				<h:form id="frm_allprivileges">
					<p:dataTable value="#{privilegeBean.privilegeList}" var="privilege"
						paginator="true" rows="20" editable="true">
						<p:column headerText="privilege ID" sortBy="#{privilege.recid}"
							filterBy="#{privilege.recid}" filterMatchMode="contains"
							style="width:auto">
							<h:outputText value="#{privilege.recid}" />
						</p:column>
						<p:column headerText="privilege Name" sortBy="#{privilege.name}"
							filterBy="#{privilege.name}" filterMatchMode="contains"
							style="width:auto">
							<h:outputText value="#{privilege.name}" />
						</p:column>
						<p:column headerText="Category Name" style="width:auto">
							<p:selectOneMenu value="#{privilege.categoryId}">
								<f:selectItem itemValue="-1" itemLabel="--Choose Category--" />
								<f:selectItems value="#{privilegeBean.categoryList}"
									var="category" itemLabel="#{category.name}"
									itemValue="#{category.recid}" />
							</p:selectOneMenu>
						</p:column>

						<p:column headerText="Options"
							tyle="font-size: smaller;text-align: center;width:auto">
							<p:commandButton
								actionListener="#{privilegeBean.toUpdatePrivilege}" ajax="true"
								image="ui-icon-pencil" title="Update" update=":frm_privilege"
								style="width: 30px;height: 30px"
								oncomplete="privilegeDlg.show();">
								<f:setPropertyActionListener value="#{privilege}"
									target="#{privilegeBean.privilege}" />
							</p:commandButton>
							<p:spacer width="20" />
							<p:commandButton action="#{privilegeBean.deletePrivilege}"
								ajax="true" onstart="waiteDialog.show();"
								oncomplete="waiteDialog.hide();" update="@form"
								style="width: 30px;height: 30px" image="ui-icon-trash"
								title="Delete">
								<f:setPropertyActionListener value="#{privilege}"
									target="#{privilegeBean.privilege}" />
							</p:commandButton>
						</p:column>
					</p:dataTable>
					<p:messages id="msgs" />
				</h:form>
			</p:panel>
			<p:dialog widgetVar="privilegeDlg" modal="true"
				header="Access Information" resizable="false">
				<h:form id="frm_privilege">
					<h:panelGrid columns="4" id="ss">
						<h:outputText value="Privilege Name" />
						<p:inputText value="#{privilegeBean.privilege.name}"
							required="true" requiredMessage="Privilege Nmae is Required" />
						<h:outputText value="Category Name" />
						<p:selectOneMenu value="#{privilege.categoryId}">
							<f:selectItem itemValue="-1" itemLabel="--Choose Category--" />
							<f:selectItems value="#{privilegeBean.categoryList}"
								var="category" itemLabel="#{category.name}"
								itemValue="#{category.recid}" />
						</p:selectOneMenu>
						<p:commandButton value="Save"
							actionListener="#{privilegeBean.savePrivilege}"
							style="height: 30px;font-size: small"
							onstart="waiteDialog.show()"
							oncomplete="waiteDialog.hide();privilegeDlg.hide();"
							update=":frm_allprivileges" />
					</h:panelGrid>
				</h:form>
			</p:dialog>
		</ui:define>
	</ui:composition>

</body>
</html>
